<template>
	<view class="home">
		
		<view class="user_top">
			<text>会员中心--添加地址</text>
		</view>
		
		<view class="input">
		   <view class="input1"><input type="text" name="username" placeholder="请输入姓名" v-model="username"/></view>
		</view>
		
		<view class="input">
		   <view class="input1"><input type="number" name="phone" placeholder="请输入收货人电话" v-model="phone"/></view>
		</view>
		
		<view class="input">
		   <view class="input1"><input type="text" name="useraddress" placeholder="请输入详细地址" v-model="useraddress"/></view>
		</view>
		
		<view class="input2">
		  <button type="primary" @click="btn_add">添加</button>
		</view>
		
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				username:"",
				phone:"",
				useraddress:"",
			}
		},
		methods: {
			back(){
				uni.navigateBack({
					delta: 1
				});
			},
			// 初始化表单
			initForm(){
				this.username = ''
				this.phone = ''
				this.useraddress = ''
			},
			async btn_add(){
                
				var res=uni.getStorageSync('my_info');
				
				const res2 = await this.$myRuquest({
					url:'/index/dsnv.activities/address_add',
					method:'post',
					data:{
						"uid":res.id,
						"username":this.username,
						"phone":this.phone,
						"useraddress":this.useraddress,
					},
				})

				if(res2.data.code ==200){
					uni.showToast({
					 	title: res2.data.info,
					 	duration: 3000,
					 	icon: 'none'
					 }),
					 
					uni.navigateTo({
						url: '/pages/my/address/address'
					});
				}else{
					uni.showToast({
						title: res2.data.info,
						duration: 3000,
						icon: 'none'
					})
				}
		
			}
		}
	}
</script>

<style>
	.home{		
		
	}
	.user_top{
		text-align: center;
	}
	
	.input{
		height: 40px;
		border-radius: 20px;
		border: 1px solid #D0D0D0;
		margin: 20px 20px;
	}
	.input1{
		padding-top:8px;
		padding-left:20px;
		height: 25px;
	}
	.input2{
		height: 40px;

	
		margin: 20px 20px;
	}
	

</style>
